<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/user/userDraw.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/area.js"></script>
  </head>
  <body>
	<div class="easyui-layout" data-options="fit:true">
		  <div data-options="region:'north',border:false,split:false">
		 	<form id="query-form" class="search_form clearfix">
		            <dl>
					<dt>省：</dt>
					 <dd>
	                	<select name="provinceId" id="provinceId" onchange="admin.area.changeProvince()" class="txt grid-8">
	                		<c:forEach var="province" items="${provinceList}">  
                                <option value="${province.id}">${province.name}</option>  
                            </c:forEach>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>市：</dt>
					 <dd>
	                	<select name="cityId" id="cityId" onchange="admin.area.changeCity()" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>区：</dt>
					 <dd>
	                	<select name="areaId" id="areaId" onchange="admin.area.changeArea()" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>社区：</dt>
					<dd>
						<select name="communityId" id="communityId" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
					</dd>
				</dl>
				<p class="cl"></p>
		            <dl>    
		                <dt>用户名称：</dt>
		                <dd>
		                	<input name="userNick" id="userNick" type="text" class="txt" maxlength="16"/>
		                </dd>
		            </dl>
		            <dl>    
		                <dt>奖品名称：</dt>
		                <dd>
		                	<input name="drawItemName" id="drawItemName" type="text" class="txt" maxlength="16"/>
		                </dd>
		            </dl>
		            <dl>    
		                <dt>抽奖活动：</dt>
		                <dd>
		                	<select name="drawBaseId" id="drawBaseId">
		                		<option value="">请选择</option>
		                		<c:forEach items="${list}" var="drawBase">
		                			<option value="${drawBase.id}">${drawBase.name}</option>
		                		</c:forEach>
		                	</select>
		                </dd>
		            </dl>
		            <p class="search_form_btn">
		            	<input type="button" value="搜索" class="icon_serach" onclick="admin.userDraw.query()" />
		            	<input type="button" value="添加" class="icon_serach" onclick="admin.userDraw.toAdd()" />
		            </p>
		        </form>
		   </div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/user/draw/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'userNick',width:80,align:'center'">用户</th>
						<th data-options="field:'communityName',width:80,align:'center'">所属社区</th>
						<th data-options="field:'status',width:100,align:'center',formatter:formatStatus">审核状态</th>
						<th data-options="field:'drawItemName',width:80,align:'center'">奖品</th>
						<th data-options="field:'strUpdAt',width:200,align:'center'">奖品领取时间</th>
						<th data-options="field:'strNewAt',width:200,align:'center' ">中奖时间</th>
			            <th data-options="field:'id',align:'center',width:150,formatter:formatOperation">管理操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	  </div>
	<script>
		function formatOperation(value,row,index) {				
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.userDraw.detail('+row.id+','+row.userId+','+row.drawItemId+')">查看</a>';
			if(row.status=="1"){
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.userDraw.unclaimed('+row.id+')">未领取</a>';
			}else if(row.status=="2"){
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.userDraw.receive('+row.id+')">已领取</a>';
			}
			/* l_html += '<a href="javascript:;" class="table_link" onclick="admin.userDraw.toUpdate('+row.id+')">编辑</a>'; */
			return l_html;
		}
		function formatStatus(value,row,index) {
			var status = row.status;//状态UserDrawStatusEnum：1-已领取；2-未领取; 3-已失效
			if(status=="1"){
				return '已领取';
			}else if(status=="2"){
				return '未领取';
			}else if(status=="3"){
				return '已失效';
			}
		}
	</script>
  </body>
</html>
